﻿namespace OP10.ViewModels
{
    public class MenuViewModel
    {

        private readonly IRegionManager _regionManager;

        public MenuViewModel(IRegionManager regionManager)
        {
            _regionManager = regionManager;


        }



        #region 事件

        private DelegateCommand _GoBackCommand;

        public DelegateCommand GoBackCommand =>
            _GoBackCommand ?? (_GoBackCommand = new DelegateCommand(ExecuteGoBackCommand));

        void ExecuteGoBackCommand()
        {
            _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.AllStationView);
        }



        /// <summary>
        /// 工站导航
        /// </summary>
        private DelegateCommand<string> _NavigateCommand;
        public DelegateCommand<string> NavigateCommand =>
            _NavigateCommand ?? (_NavigateCommand = new DelegateCommand<string>(ExecuteNavigateCommand));

        void ExecuteNavigateCommand(string parameter)
        {
            NavigationParameters param = new NavigationParameters();
            param.Add("StationName", parameter);
            param.Add("NavigateFrom", AppViews.MenuView);

            //根据参数跳转到对应的工站页面
            switch (parameter)
            {
                case "ST01":
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.ST01View, param);
                    break;
                case "ST02":
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.ST02View, param);
                    break;
                case "ST03":
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.ST03View, param);
                    break;
                case "ST04":
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.ST04View, param);
                    break;
                case "ST05":
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.ST05View, param);
                    break;
                case "ST06":
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.ST06View, param);
                    break;
                case "ST07":
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.ST07View, param);
                    break;
                case "ST08":
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.ST08View, param);
                    break;
                case "ST09":
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.ST09View, param);
                    break;
                case "ST10":
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.ST10View, param);
                    break;
                case "ST11":
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.ST11View, param);
                    break;
                case "ST12":
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.ST12View, param);
                    break;

                case "ST13":
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.ST13View, param);
                    break;
                case "PingBi":
                    if (!LoginInfo.IsLogin)
                    {
                        MessageBox.Show("请登录用户,再进入!");
                        return;
                    }
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.PingBiView, param);
                    break;
                case "Statistics":
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.ProductStatisticView, param);
                    break;
                case "IO":
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.IOMonitorView, param);
                    break;
                case "寿命管控":
                    if (!LoginInfo.IsLogin)
                    {
                        MessageBox.Show("请登录用户,再进入!");
                        return;
                    }
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.LifeControlView, param);
                    break;
                case "连续NG数设置":
                    if (!LoginInfo.IsLogin)
                    {
                        MessageBox.Show("请登录用户,再进入!");
                        return;
                    }
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName, AppViews.ContinuousNgView, param);
                    break;

                case "CT统计":
                    _regionManager.RequestNavigate(PrismManager.MainViewRegionName,AppViews.CycleTimeStatisticView, param);
                    break;
                default:
                    break;
            }


        }



        #endregion
    }
}
